import request from './request'
import { Toast } from 'vant'

let corestr = String.raw`
$$\   $$\  $$$$$$\   $$$$$$\        $$$$$$$\   $$$$$$\  $$\     $$\ 
$$ |  $$ |$$$ __$$\ $$  __$$\       $$  __$$\ $$  __$$\ \$$\   $$  |
$$ |  $$ |$$$$\ $$ |$$ /  \__|      $$ |  $$ |$$ /  $$ | \$$\ $$  / 
$$$$$$$$ |$$\$$\$$ |$$$$$$$\        $$$$$$$\ |$$ |  $$ |  \$$$$  /  
\_____$$ |$$ \$$$$ |$$  __$$\       $$  __$$\ $$ |  $$ |   \$$  /   
      $$ |$$ |\$$$ |$$ /  $$ |      $$ |  $$ |$$ |  $$ |    $$ |    
      $$ |\$$$$$$  / $$$$$$  |      $$$$$$$  | $$$$$$  |    $$ |    
      \__| \______/  \______/       \_______/  \______/     \__|    
                                                                    
                                                                    
                                                                    
      $$\     $$\ $$\     $$\ $$$$$$$\   $$$$$$\                    
      \$$\   $$  |\$$\   $$  |$$  __$$\ $$  __$$\                   
       \$$\ $$  /  \$$\ $$  / $$ |  $$ |$$ /  \__|                  
        \$$$$  /    \$$$$  /  $$ |  $$ |\$$$$$$\                    
         \$$  /      \$$  /   $$ |  $$ | \____$$\                   
          $$ |        $$ |    $$ |  $$ |$$\   $$ |                  
          $$ |        $$ |    $$$$$$$  |\$$$$$$  |                  
          \__|        \__|    \_______/  \______/                   
                                                                    
                                                                    
`;
console.log("%c%s", "color: brown", corestr);
let extend = function (destination, source) {
    for (var property in source) {
        destination[property] = source[property];
    }
    return destination;
}
let outData = {};

/**
 * 歌词请求工具
 * @param {string} id 
 * @param {(data: Object)=>void} callback 
 * @param {boolean} showError
 */
let request_getPlayUrl = (id, callback,showError=true) => {
    request("GET", "http://43.138.191.216:3000/song/url/v1?id=" + id + "&level=lossless", {}, null, () => {
        if(showError)Toast("歌曲加载失败，可能需要开通VIP");
    }).then((data) => {
        callback(data.data[0]);
    });
}

let request_getLyric = (id, callback) => {
    request("get", "/lyric?id=" + id,()=>{
        callback(null);
    }).then(function (data) {
        callback(data);
    });
}
extend(outData,{request_getPlayUrl,request_getLyric})




export default outData